<!DOCTYPE html>
<html lang="en" xmlns:layout="http://www.w3.org/1999/xhtml" layout:decorator="layout/layout"
      xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习链接</title>

</head>
<body>
<div id="page-wrapper" class="gray-bg dashbard-1">
    <div class="row wrapper border-bottom white-bg page-heading"  layout:fragment="header">
        <div class="col-lg-10">
            <h2>主页/学习链接/编辑信息</h2>
            <h2 id="menuTitle" style="display: none">学习链接</h2>
        </div>
    </div>

    <div class="row"  layout:fragment="content">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>信息详情</h5>
                </div>
                <div class="ibox-content">
                    <form method="post"  enctype="multipart/form-data" class="form-horizontal col-sm-8 col-sm-offset-2" >
                        <div class="form-group">
                            <input id="id" type="hidden" th:value="${dto.id}">
                            <label class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-9">
                                <input id="title" th:value="${dto.title}" type="text" class="form-control" placeholder="请在此输入标题">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <span id="titleSpan" style="color: red"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">作者</label>
                            <div class="col-sm-9">
                                <input id="author" th:value="${dto.author}" type="text" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <span id="authorSpan" style="color: red"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">文章类型</label>
                            <div class="col-sm-9">
                                <input id="type" th:value="${dto.type}" type="text" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <span id="typeSpan" style="color: red"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">文章路径</label>
                            <div class="col-sm-9">
                                <input id="url" th:value="${dto.url}" type="text" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-9">
                                <span id="urlSpan" style="color: red"></span>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="form-group text-center">
                            <button id="save" onclick="saveInfo()" class="btn btn-w-m btn-success" type="button">发表</button>
                            <a id="return" class="btn btn-w-m btn-primary"  th:href="@{/page/learning-link}">返回</a>
                        </div>
                    </form>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
        <script type="text/javascript" th:inline="javascript">
            
            function saveInfo() {
                var data = {
                    "id":$("#id").val(),
                    "title":$("#title").val(),
                    "author":$("#author").val(),
                    "type":$("#type").val(),
                    "url":$("#url").val(),
                }
                $.ajax({
                    url:baseUrl+"/learning-links",
                    cache:false,
                    type:"POST",
                    dataType:"json",
                    data:data,
                    success:function (r) {
                        if (r.code == 0){
                            window.location.href=baseUrl+"/page/learning-link";
                        }else {
                            swal(r.msg);
                        }
                    }
                })
            }
        </script>
    </div>
</div>
</body>
</html>